
Ext.onReady(function(){
  Ext.QuickTips.init();
  var dbStore = new Ext.data.JsonStore({
    url: '/source/db/db.php?act=getDBs',
    root: 'dbs',
    fields: ['Database']
  });

  var db_combo = new Ext.form.ComboBox({
    store: dbStore,
    displayField: 'Database',
    valueField:'Database',    
    typeAhead: true,
    mode: 'remote',
    forceSelection: true,
    triggerAction: 'all',
    emptyText: curDB,
    selectOnFocus: true,
    width:147,
    editable:false,
    style:"margin-left:10px;"
  });

 

  var tb = new Ext.Toolbar();
  tb.render('toolbar');

  tb.add({
    text:'Server Info',
     cls:"menu-text",
    iconCls: 'server-ico',
    menu: {
      items:[
      {
        text:'Variables',
        cls:"menu-text",
        iconCls:"variables-ico",
        handler : function(item){          
          addTab("Variables","/source/tools/variables.php",true,"variables-ico","variablesTab" );
        }

      },

      {
        text:'Status',
        cls:"menu-text",
        iconCls:"status-ico",
        handler : function(item){
          addTab("Status","/source/tools/status.php",true,"status-ico","statusTab" );
        }

      },
      {
        text:'Charsets',
        cls:"menu-text",
        iconCls:"charset-ico",
        handler : function(item){
          addTab("Charsets","/source/tools/charsets.php",true,"charset-ico","charsetsTab" );
        }
      }
      ]
    }  // assign menu by instance
  },'-',{
    text:'Database',
    cls:"menu-text",
    iconCls:'database-ico',
    menu : {
      items :[{
        text:"Import",
        cls:"menu-text",
        iconCls:"import-ico"
      },{
        text:"Export",
        cls:"menu-text",
        iconCls:"export-ico",
        menu :{
          items:[
          {
            text:"CSV File",
            cls:"menu-text",
            iconCls:"csv-ico"
          },

          {
            text:"SQL File",
            cls:"menu-text",
            iconCls:"sql-ico"
          }
          ]
        }
      }]
    }
  },'-',{

    text:"SQL Query",
    cls:"menu-text",
    iconCls:"sql-ico"
  },'-',
  {
    text:"Tools",
    cls:"menu-text",
    iconCls:"tools-ico",
    menu:{
      style: {
        overflow: 'visible'     // For the Combo popup
      },
      items:[
      new Ext.ux.ThemeCombo({
        id:'theme-combo',
        width:130,
        iconCls: 'no-icon'
      })
      ]
    }
  },
  {
    text:"Help",
    cls:"menu-text",
    iconCls:"help-ico",
    menu :{
      items : [{
        text:"FAQ",
        cls:"menu-text",
        iconCls:"faq-ico"
      },{
        text:"About",
        cls:"menu-text",
        iconCls:"crab-logo"
      }]
    }
  },'-',
  db_combo
  
  );
  
  tb.doLayout();

  function menuItemClick(item,tt){
    alert(tt);
  }

}
);